package com.example.tliasmanagement.mapper;

import com.example.tliasmanagement.dto.ClazzListDto;
import com.example.tliasmanagement.entity.Clazz;
import com.example.tliasmanagement.entity.Student;
import com.example.tliasmanagement.vo.ClazzListVo;
import com.example.tliasmanagement.vo.EmpVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {
    public List<EmpVo> selectAll();

    @Select("select count(id) from clazz")
    int totalCount();

    List<ClazzListVo> selectPage(@Param("start") int start, @Param("pageSize")Integer pageSize);

    List<Clazz> page(ClazzListDto dto);

    /*@Select("select * from clazz where username = #{username}")
    Clazz selectByUsername(String username);*/

    @Insert("insert into clazz(name,room, begin_date, end_date,master_id,subject,create_time, update_time)" +
            "values(#{name},#{room}, #{beginDate}, #{endDate},#{masterId},#{subject},#{createTime}, #{updateTime} )")
    void insert(Clazz clazz);

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    @Select("select * from clazz where id=#{id}")
    Clazz selectById(Integer id);

    @Update("update clazz set name=#{name},room=#{room},begin_date=#{beginDate},end_date=#{endDate},master_id=#{masterId},subject=#{subject} where id=#{id}")
    void update(Clazz clazz);


    @Select("select * from student where clazz_id= #{clazzId}")
    List<Student> getClazzId(Integer id);


}
